home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
misc_pto
/
mwpetz06
/
digclock.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-15
|
2KB
|
63 lines
#include "digclock.hpp"
clockPane::clockPane(Window *w): TextPane(w) {
setSizeWithParent();
String cName("intl");
iDate=GetProfileInt(cName,"iDate",0);
iTime=GetProfileInt(cName,"iTime",0);
GetProfileString(cName,"sDate","/", sDate, 2);
GetProfileString(cName,"sTime",":", sTime, 2);
GetProfileString(cName,"s1159","AM",sAMPM [0],5);
GetProfileString(cName,"s2359","PM",sAMPM [1],5);
create(0,SW_SHOWNOACTIVATE);
tim=new Timer(1,this,(TimerProc)clockPane::tick);
}
clockPane::~clockPane() {
delete tim;
}
void clockPane::tick() {
static char szWday[] = "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat" ;
char cBuffer[40] ;
long lTime ;
RECT rect ;
short nLength ;
struct tm *datetime ;
time(&lTime) ;
datetime=localtime(&lTime) ;
nLength = wsprintf(cBuffer," %s %d%s%02d%s%02d \n",
(LPSTR) szWday + 4 * WDAY,
iDate==1 ? MDAY :iDate==2 ? YEAR :MONTH,sDate,
iDate==1 ? MONTH:iDate==2 ? MONTH:MDAY,sDate,
iDate==1 ? YEAR :iDate==2 ? MDAY :YEAR);
if (iTime==1)
nLength+=wsprintf(cBuffer + nLength, " %02d%s%02d%s%02d ",
HOUR, (LPSTR) sTime, MIN, (LPSTR) sTime, SEC) ;
else
nLength+=wsprintf(cBuffer + nLength, " %d%s%02d%s%02d %s ",
(HOUR % 12) ? (HOUR % 12) : 12,
(LPSTR) sTime, MIN, (LPSTR) sTime, SEC,
(LPSTR) sAMPM [HOUR / 12]) ;
moveTo(0,0);
printf(cBuffer);
}
MainFrame::MainFrame() :AppFrame("zApp DigClock") {
create(0,SW_SHOWNOACTIVATE);
p=new clockPane(this);
}
void App::main() {
MainFrame *p=new MainFrame();
app->go();
delete p;
}